import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
import loading from "@/components/fnCom/loadingFn"
const DRequest = axios.create({
    baseURL: 'http://localhost:3000',
    timeout: 3666
})
DRequest.interceptors.request.use((c: AxiosRequestConfig) => {
    loading()
    return c
})
// 泛型T用来指定Reponse类型中result的类型
export default <T = any>(config: AxiosRequestConfig) => {
    return DRequest.request<T>(config).then((response: AxiosResponse<T>) => {
        loading(true)
        return response.data
    })
}

